const userDao = require("../dao/userDao");
let user = {
  login(req, res) {
    //请求数据的获取,筛选
    let useremail = req.body.useremail;
    let password = req.body.password;
    let userArr = [useremail, password];
    userDao.login(userArr, function (err, data) {
      if (data.length) {
        res.redirect("/index.html");
      } else {
        res.redirect("/page/404.html");
      }
    });
  },
  register(req, res) {
    let useremail = req.body.useremail;
    let password = req.body.userpassword;
    let userArr = [password, useremail];
    console.log(userArr);
    userDao.addUser(
      'insert into users values(null,"xiao","wang","xiaowang",?,?)',
      userArr,
      function (err, data) {
        if (data) {
          console.log("注册成功");
        } else {
          console.log("注册失败");
        }
      }
    );
  },
};

module.exports = user;
